﻿//创建时间: 2010-12-15
//创建作者: 李 城
//功能说明: cms外部页面访问基类 评论数目
//最后修改: 2010-12-15
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Web;

using TRPOP.Config;
using TRPOP.Common;

namespace TRPOP.CMS.Web.ExtraBus
{
    /// <summary>
    /// 评论数目
    /// </summary>
    public class Page_Load_RecCount : BasePage
    {
        protected override void OnInit(EventArgs e)
        {
            string strRecCountPage = SYSConfig.RecommentConfigerInfo.URL_GetCount.Remove(SYSConfig.RecommentConfigerInfo.URL_GetCount.IndexOf("?"));
            string strDynamicPageName  
                = (base.mCurrentUrl.ToLower().Contains(strRecCountPage.ToLower().Trim())) ? "RecCountPage" : "";
            if (strDynamicPageName == "RecCountPage")
                Rec_GetRecCount();
            else
                Base_Config.NotFound(base.Page, "CMS后台配置的页面地址和访问的页面不一致(评论)");
            //base.OnInit(e);
        }
        /// <summary>
        /// 评论数目
        /// </summary>
        public void Rec_GetRecCount()
        {
            Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            RecomManage oRecomManage = new RecomManage();
            string ResJs = string.Empty;
            if (RequestHelper.RequestString("type") == "content")
            {
                ResJs = "{0}";
            }
            else
            {
                ResJs = "document.writeln(\"{0}\");";
            }
            //信息评论
            int intIndexid = RequestHelper.RequestInt("id");
            if (intIndexid > 0)
            {
                ResJs = string.Format(ResJs, oRecomManage.GetContentRecCount(intIndexid).ToString());
            }
            //结点评论
            int intNodeid = RequestHelper.RequestInt("NodeID");
            if (intNodeid > 0)
            {
                ResJs = string.Format(ResJs, oRecomManage.GetNodeRecCount(intNodeid).ToString());
            }
            Response.Write(string.Format(ResJs, 0));
        }
    }
}
